Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-helpers

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-helpers

Use async helpers in templates with engines that typically only handle sync helpers. Handlebars and Lodash have been tested.

  • 0.2.5
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

async-helpers NPM version Build Status

Use async helpers in templates with engines that typically only handle sync helpers. Handlebars and Lodash have been tested.

Install with npm

$ npm i async-helpers --save

Usage

var asyncHelpers = require('async-helpers');

API

AsyncHelpers

Create a new instance of AsyncHelpers

  • returns {Object}: new AsyncHelpers instance

Example

var asyncHelpers = new AsyncHelpers();

.set

Add a helper to the cache.

Params

  • name {String}: Name of the helper
  • fn {Function}: Helper function
  • returns {Object}: Returns this for chaining

Example

asyncHelpers.set('upper', function (str, cb) {
  cb(null, str.toUpperCase());
});

.get

Get all helpers or a helper with the given name.

Params

  • name {String}: Optionally pass in a name of a helper to get.
  • options {Object}: Additional options to use.
  • returns {Function|Object}: Single helper function when name is provided, otherwise object of all helpers

Example

var helpers = asyncHelpers.get();
var wrappedHelpers = helperAync.get({wrap: true});

.wrap

Wrap a helper with async handling capibilities.

Params

  • name {String}: Optionally pass the name of the helper to wrap
  • returns {Function|Object}: Single wrapped helper function when name is provided, otherwise object of all wrapped helpers.

Example

var wrappedHelper = asyncHelpers.wrap('upper');
var wrappedHelpers = asyncHelpers.wrap();

.reset

Reset all the stashed helpers.

  • returns {Object}: Returns this to enable chaining

Example

asyncHelpers.reset();

.resolve

Resolve a stashed helper by the generated id.

Params

  • key {String}: ID generated when from executing a wrapped helper.
  • cb {Function}: Callback function with the results of executing the async helper.

Example

var upper = asyncHelpers.get('upper', {wrap: true});
var id = upper('doowb');
asyncHelpers.resolve(id, function (err, result) {
  console.log(result);
  //=> DOOWB
});
  • engine-cache: express.js inspired template-engine manager.
  • helper-cache: Easily register and get helper functions to be passed to any template engine or node.js… more
  • template-helpers: Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or… more

Run tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Brian Woodward

License

Copyright © 2015 Brian Woodward Released under the MIT license.


This file was generated by verb-cli on June 05, 2015.

Keywords

FAQs

Package last updated on 05 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc